package com.sun.huazhi.aitaskservice.service.impl;

import com.sun.huazhi.aitaskservice.DTO.response.VideoTaskResponse;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class VideoTaskStoreService {

    private final Map<String, VideoTaskResponse> taskStore = new ConcurrentHashMap<>();

    public void savePending(String taskId) {
        taskStore.put(taskId, new VideoTaskResponse(taskId, "pending", null));
    }

    public void saveResult(String taskId, VideoTaskResponse result) {
        taskStore.put(taskId, result);
    }

    public Mono<VideoTaskResponse> getTask(String taskId) {
        return Mono.justOrEmpty(taskStore.get(taskId));
    }
}
